package com.qqtech.qquan.circle.dao;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;

import com.qqtech.core.common.util.BeanUtil;
import com.qqtech.core.frame.dao.BaseDaoImpl;
import com.qqtech.qquan.circle.model.CircleBase;
import com.qqtech.qquan.circle.model.CircleBaseQuery;
import com.qqtech.qquan.circle.model.CircleBaseVo;

@Repository
public class CircleBaseDaoImpl extends BaseDaoImpl<CircleBase> implements CircleBaseDao {
	public static final Logger log = LoggerFactory.getLogger(CircleBaseDaoImpl.class);
	
	@Override
	public List<CircleBaseVo> queryMyOrderlyCircles(Integer userId) {
		return sqlSessionTemplate.selectList(getSqlName("queryMyOrderlyCircles"), userId);
	}
	
	@Override
	public int queryCountAdmin(CircleBaseQuery query) {
		return sqlSessionTemplate.selectOne(getSqlName("selectCountAdmin"), BeanUtil.toMap(query));
	}
	
	@Override
	public Page<CircleBaseVo> queryPageListAdmin(CircleBaseQuery query,
			Pageable pageable) {
		List<CircleBaseVo> contentList = sqlSessionTemplate.selectList(getSqlName("selectAdmin"), getParams(query, pageable));
		return new PageImpl<CircleBaseVo>(contentList, pageable, this.queryCountAdmin(query));
	}
	
}
